﻿using DesignPatterns.FactoryMethod;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DesignPatterns.Decorator
{
    public partial class FrmFactoryMethod : FrmBase
    {
        public List<IFactory> Factories { get; set; }

        public FrmFactoryMethod()
        {
            InitializeComponent();

            cmbLeiFeng.SelectedIndex = 0;
            Factories = new List<IFactory> { new UndergraduateFactory(), new VolunteerFactory() };

            btnRun.Click += BtnRun_Click;
        }

        private void BtnRun_Click(object sender, EventArgs e)
        {
            labResult.Text = "";
            var factory = Factories[cmbLeiFeng.SelectedIndex];
            var leifeng = factory.CreateLeiFeng();
            labResult.Text += leifeng.BuyRice();
            labResult.Text += "、" + leifeng.Wash();
            labResult.Text += "、" + leifeng.Sweep();
            labResult.Text += $"（来自：{leifeng.Identity}）";
        }
    }
}
